<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
    <link rel="stylesheet" href="preview/css/reset.css"/>
    <script src="dragStatic/js/jquery-3.2.1.min.js"></script>
    <script src="preview/js/rem.js"></script>
    <script src="dragStatic/js/common.js"></script>
    <title>大数据单模块-时间</title>
    <style>
        *{
            padding:0;
            margin:0;
            box-sizing: border-box;
        }
        html,body{width: 100%;height: 100%}
        .time{width: 100%;height: 100%;font-size:0.14rem;color:#b5b5b5;}
        .time_down{height: 0.52rem;}
        ._timeLeft{font-size:0.3rem;float: left;margin-right:0.02rem;}
        ._timeRight{float: left;height: 100%;}
        ._timeRight p:nth-of-type(2){font-size:0.12rem;}
        /*1366下面*/
        @media screen and (max-width: 160px) {
            ._timeRight p:nth-of-type(2) {
                font-size:10px;
                margin-top:-6px;
            }
        }



    </style>
</head>
<body>
    <!--时间-->
    <div class="time">
        <div class="date"></div>
        <div class="time_down">
            <div class="_timeLeft"></div>
            <div class="_timeRight">
                <p class="seconds"></p>
                <p>current time</p>
            </div>
        </div>
        <div class="block"></div>
    </div>
</body>
<script>
    window.onresize = function(){
        page_init(100,200,"时间日期");
    };
    window.onload = function(){
        page_init(100,200,"时间日期");
        requestAnimationFrame(startTime);
//        var obj={"maxW":960,"maxH":70,"minW":160,"minH":48};
        divFlex("time");////调用缩放功能
        function startTime() {
            cancelAnimationFrame(startTime);
            var today = new Date(); //定义日期对象
            var ss = today.getSeconds(); //通过日期对象的getSeconds方法返回秒
            var yyyy = today.getFullYear(); //通过日期对象的getFullYear()方法返回年
            var MM = today.getMonth() + 1; //通过日期对象的getMonth()方法返回年
            var dd = today.getDate(); //通过日期对象的getDate()方法返回年
            var hh = today.getHours(); //通过日期对象的getHours方法返回小时
            var mm = today.getMinutes(); //通过日期对象的getMinutes方法返回分钟
            // 如果分钟或小时的值小于10，则在其值前加0，比如如果时间是下午3点20分9秒的话，则显示15：20：09
            MM = checkTime(MM);
            dd = checkTime(dd);
            mm = checkTime(mm);
            ss = checkTime(ss);
            var day; //用于保存星期（getDay()方法得到星期编号）
            if (today.getDay() == 0) day = "星期日 "
            if (today.getDay() == 1) day = "星期一 "
            if (today.getDay() == 2) day = "星期二 "
            if (today.getDay() == 3) day = "星期三 "
            if (today.getDay() == 4) day = "星期四 "
            if (today.getDay() == 5) day = "星期五 "
            if (today.getDay() == 6) day = "星期六 "
            $(".date").text(yyyy+"年"+MM+"月"+dd+"日 "+day);
            $("._timeLeft").text(checkTime(hh)+":"+mm);
            $(".seconds").html(ss);
            requestAnimationFrame(startTime);
        }
        function checkTime(i) {
            if (i < 10) {
                i = "0" + i;
            }
            return i;
        }//判断是否小于0

    }
</script>
</html>

